import request from '@/utils/axios';
import { auth } from '@/config/env';

export const page = params => {
  return request({
    url: auth + '/user/page',
    method: 'post',
    data: params,
  });
};

export const save = model => {
  return request({
    url: auth + '/user',
    method: 'post',
    params: model,
  });
};

export const edit = model => {
  return request({
    url: auth + '/user/' + model.id,
    method: 'put',
    params: model,
  });
};

export const del = id => {
  return request({
    url: auth + '/user/' + id,
    method: 'delete',
  });
};

export const batDel = ids => {
  return request({
    url: auth + '/user',
    method: 'delete',
    data: ids,
  });
};

export const isLock = model => {
  return request({
    url: auth + '/user/isLock/' + model.id,
    method: 'put',
    params: {
      status: model.status
    },
  });
};

export const pageUserRole = (userId, param) => {
  return request({
    url: auth + '/user/' + userId + '/role/page',
    method: 'post',
    data: param,
  });
};

export const findUserRole = id => {
  return request({
    url: auth + '/user/' + id + '/role/find',
    method: 'get',
  });
};

export const saveUserRole = model => {
  return request({
    url: auth + '/user/' + model.id + '/role',
    method: 'post',
    data: model.detail,
  });
};
